package com.youlian.utils;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;

import com.youlian.activity.R;
import com.youlian.common.Configure;

public class DialogPopWindow {
	
	private Context mContext;
	private PopupWindow mWindow;
	private View popView;
	
	public  DialogPopWindow(Context mContext,View view){
		this.mContext= mContext;
		this.popView = view;
		
	}
	/**
	 * view 为window依附的view
	 * @param view
	 */
	public void showPopDialog(View parent){
		
		if (null == mWindow) {
//			View cateView = mContex.getLayoutInflater().inflate(
//					R.layout.action_pop, null);
			mWindow = new PopupWindow(this.popView,LayoutParams.FILL_PARENT,
					Configure.screenHeight/2);
			mWindow.setBackgroundDrawable(new BitmapDrawable());
			mWindow.setAnimationStyle(R.style.roll);
			mWindow.setFocusable(true);
			mWindow.setTouchable(true);
			mWindow.setOutsideTouchable(true);
			mWindow.update();
		}
		if (mWindow.isShowing()) {
			mWindow.dismiss();
		} else {
			mWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
		}
		
	}

}
